package com.ruoyi.crm.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.excel.utils.ExcelUtil;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.crm.domain.TrackingRecord;
import com.ruoyi.crm.service.ITrackingRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 *
 * 跟进记录控制层
 * @author  dxy
 *
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/tracking")
public class TrackingRecordController extends BaseController {

    private final ITrackingRecordService trackingRecordService;
    /**
     * 查询跟进记录列表
     */
    @SaCheckPermission("tracking:trackingRecord:list")
    @GetMapping("/list")
    public TableDataInfo<TrackingRecord> selectTrackingPageList(TrackingRecord trackingRecord, PageQuery pageQuery){
        TableDataInfo<TrackingRecord> list = trackingRecordService.selectTrackingPageList(trackingRecord,pageQuery);
        list.getRows().forEach(T->{
        });
        return list;

    }

    /**
     * 根据跟进记录ID查询获取详细信息
     */
    @SaCheckPermission("tracking:trackingRecord:query")
    @GetMapping("/{trackingId}")
    public R<TrackingRecord> selectTrackingRecordById(@PathVariable Long trackingId){
        return R.ok(trackingRecordService.selectTrackingById(trackingId));
    }
    /**
     * 删除跟进记录
     */
    @SaCheckPermission("tracking:trackingRecord:remove")
    @Log(title = "跟进记录",businessType = BusinessType.DELETE)
    @DeleteMapping("/{trackingId}")
    public R<Void> deleteTrackingRecordById(@PathVariable Long trackingId){
        return toAjax(trackingRecordService.delectTrackingById(trackingId));
    }



}
